<?php
declare(strict_types=1);
namespace Service\GoodsService;
use Service\BaseService;
use App\Model\BbcModel\GoodsSpecPrice;

/**
 * 商品规格价格服务中心
 * @author chenshubo
 */
class GoodsSpecPriceService extends BaseService
{
    const TYPE_PRICE_MONEY  = 0;
    const TYPE_PRICE_RATE   = 1;
    const TYPE_PRICE_IMPORT = 2;
    /**
     * 获取商品规格价格
     * @param array $goodsIds
     */
    public function getGoodsSpecPriceList( array $goodsIds)
    {
        return GoodsSpecPrice::instance()->whereIn('goods_id',$goodsIds)->get()->toArray();
    }
    
    /**
     * 获取分组功能
     * @param array $data
     */
    public function getMapList( array $data )
    {
        if( empty($data) ) {
            return [];
        }
        
        $temp = [];
        foreach ($data as $item)
        {
            $temp[$item['goods_id']][$item['spec_num']] = $item;
            unset($item);
        }
        
        return $temp;
    }
}